package com.leyou.item.api;

import com.leyou.common.pojo.PageResult;
import com.leyou.item.bo.SpuBo;
import com.leyou.item.pojo.Sku;
import com.leyou.item.pojo.Spu;
import com.leyou.item.pojo.SpuDetail;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

public interface GoodsApi {
    /**
     * 根据条件分页查询spu
     *
     * @param key
     * @param saleable
     * @param page
     * @param rows
     * @return
     */
    @GetMapping("/spu/page")
    public PageResult<SpuBo> querySpuBoByPage(
            @RequestParam(value = "key", required = false) String key,
            @RequestParam(value = "saleable", required = false) Boolean saleable,
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows
    );

    /**
     * 新增商品
     *
     * @param spuBo
     * @return
     */
    @PostMapping("/goods")
    public Void saveGoods(@RequestBody SpuBo spuBo);

    /**
     * 更新商品信息
     *
     * @param spuBo
     * @return
     */
    @PutMapping("/goods")
    public Void updateGoods(@RequestBody SpuBo spuBo);

    /**
     * 根据spuId查询spuDeatil
     *
     * @param spuId
     * @return
     */
    @GetMapping("/spu/detail/{spuId}")
    public SpuDetail querySpuDetailBySpuId(@PathVariable("spuId") Long spuId);

    /**
     * 根据spuId查询sku集合
     *
     * @param spuId
     * @return
     */
    @GetMapping("/sku/list")
    public List<Sku> querySkusBySpuId(@RequestParam("id") Long spuId);
    /**
     * 根据id查询spu
     * @param spuId
     * @return
     */
    @GetMapping("{id}")
    public Spu querySpuById(@PathVariable("id")Long spuId);

    /**
     * 根据skuId查询sku
     * @param skuId
     * @return
     */
    @GetMapping("/sku/{skuId}")
    public Sku querySkuBySkuId(@PathVariable("skuId")Long skuId);
}